SPDK_DIR = /root/liujie/spdk
SPDK_INCLUDE_DIR = $(SPDK_DIR)/include
RPC_DIR = ../mrpc
SPDK_LIB_DIR = $(SPDK_DIR)/build/lib
DPDK_LIB_DIR = $(SPDK_DIR)/dpdk/build/lib
DPDK_CFLAGS = -lrte_eal -lrte_mempool -lrte_ring -lrte_mbuf -lrte_bus_pci -lrte_pci -lrte_mempool_ring -lrte_power -lrte_ethdev -lrte_net -lrte_telemetry \
 -lrte_kvargs -lrte_vhost -lrte_cryptodev -lrte_hash -lrte_rcu
SPDK_CFLAGS = -lspdk_log -lspdk_event -lspdk_env_dpdk -lspdk_util -lspdk_blob -lspdk_blob_bdev -lspdk_bdev_malloc -lspdk_bdev -lspdk_event_bdev -lspdk_thread \
 -lspdk_bdev_nvme -lspdk_nvme -lspdk_accel -lspdk_ioat -lspdk_bdev_aio -lspdk_bdev_delay -lspdk_bdev_error -lspdk_bdev_ftl -lspdk_bdev_gpt -lspdk_bdev_lvol\
 -lspdk_bdev_null -lspdk_bdev_passthru -lspdk_bdev_raid -lspdk_bdev_split -lspdk_bdev_virtio -lspdk_bdev_zone_block -lspdk_blobfs -lspdk_blobfs_bdev \
 -lspdk_event_accel -lspdk_event_iscsi -lspdk_event_nbd -lspdk_event_nvmf -lspdk_init -lspdk_ftl -lspdk_ioat -lspdk_json -lspdk_iscsi -lspdk_jsonrpc \
 -lspdk_conf -lspdk_event_scsi -lspdk_dma -lspdk_env_dpdk_rpc -lspdk_lvol -lspdk_nbd -lspdk_notify -lspdk_nvmf -lspdk_scsi -lspdk_rpc -lspdk_sock -lspdk_sock_posix \
 -lspdk_trace -lspdk_vhost -lspdk_vmd -lspdk_virtio
 COMPILE_CFLAGS = -O2 -std=gnu++11
 EXTERNAL_LIB_FLAG = -lmrpc  -libverbs -lstdc++
chunkserver: OpHandler.o Service.o ChunkStore.o 
	g++ ${COMPILE_CFLAGS} OpHandler.o Service.o ChunkStore.o -o chunkserver ${EXTERNAL_LIB_FLAG} \
	-L${RPC_DIR} -L${SPDK_LIB_DIR} -L${DPDK_LIB_DIR}  ${DPDK_CFLAGS} ${SPDK_CFLAGS}

OpHandler.o : OpHandler.cc OpHandler.h ChunkStore.h
	g++ -c ${COMPILE_CFLAGS} OpHandler.cc -I${SPDK_INCLUDE_DIR} -I${RPC_DIR}

Service.o : Service.cc Service.h ChunkStore.h
	g++ -c ${COMPILE_CFLAGS} Service.cc -I${SPDK_INCLUDE_DIR} -I${RPC_DIR}

ChunkStore.o : ChunkStore.cc ChunkStore.h dss_common.h 
	g++ -c ${COMPILE_CFLAGS} ChunkStore.cc -I${SPDK_INCLUDE_DIR} -I${RPC_DIR}

subsystem:
	cd ../mrpc && ${MAKE}
clean:
	rm -rf *.o chunkserver
